package com.fyl.oauth2.config;

import com.fyl.oauth2.dao.AuthorizationCodeMapper;
import com.fyl.oauth2.domain.MyBatisRegisteredClientRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClient;
import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository;
import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings;
import org.springframework.security.oauth2.server.authorization.settings.ClientSettings;

import java.util.UUID;

@Configuration
public class OAuth2AuthorizationServerConfig {

    private final MyBatisRegisteredClientRepository myBatisRegisteredClientRepository;

    private final AuthorizationCodeMapper authorizationCodeMapper;

    public OAuth2AuthorizationServerConfig(AuthorizationCodeMapper authorizationCodeMapper,MyBatisRegisteredClientRepository myBatisRegisteredClientRepository) {
        this.authorizationCodeMapper = authorizationCodeMapper;
        this.myBatisRegisteredClientRepository = myBatisRegisteredClientRepository;
    }


    @Bean
    public RegisteredClientRepository registeredClientRepository(){
        //
        return myBatisRegisteredClientRepository;

    }


    @Bean
    public AuthorizationServerSettings authorizationServerSettings(){
        return AuthorizationServerSettings.builder().build();
    }
}
